package com.zlf.sb.demo.design.chain;

import com.zlf.sb.demo.vo.ProductUpShelfReqDTO;
import org.springframework.stereotype.Component;

@Component
public class ProductInventoryCheckChainFilter implements MerchantAdminAbstractChainHandler<ProductUpShelfReqDTO> {
    @Override
    public void handler(ProductUpShelfReqDTO requestParam) {
        if (requestParam.getStock() <= 0) {
            throw new RuntimeException("商品库存不足，无法上架！");
        }
        System.out.println("商品库存校验通过");
    }

    @Override
    public int getOrder() {
        return 2;
    }

    @Override
    public String mark() {
        return ChainBizMarkEnum.MERCHANT_ADMIN_PRODUCT_UPSHELF_KEY.name();
    }
}